﻿<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../helpproject.xsl" ?>
<topic template="Default" lasteditedby="Geert" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../helpproject.xsd">
  <title translate="true">SplashScreenService</title>
  <body>
    <header>
      <para styleclass="Heading1"><text styleclass="Heading1" translate="true">SplashScreenService</text></para>
    </header>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">The ISplashScreenService allows a developer execute a batch of tasks en-queued and show the progress through a registered </text><link displaytype="text" defaultstyle="true" type="topiclink" href="T_Catel_MVVM_Services_IPleaseWaitService" styleclass="Normal" translate="true">IPleaseWaitService</link><text styleclass="Normal" translate="true"> or </text><link displaytype="text" defaultstyle="true" type="topiclink" href="T_Catel_MVVM_Services_IUIVisualizerService" styleclass="Normal" translate="true">IUIVisualizerService</link><text styleclass="Normal" translate="true"> type, from the main entry point of the application (typically from the bootstrapper) or a view model. </text></para>
    <para styleclass="Normal"><table styleclass="Default" rowcount="8" colcount="2">
      <tr style="vertical-align:top">
        <td style="width:181px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" style="font-weight:bold;" translate="true">Feature</text></para>
        </td>
        <td style="width:82px;">
          <para styleclass="Normal (list)" style="text-align:center;"><text styleclass="Normal (list)" style="font-weight:bold;" translate="true">Supported</text></para>
        </td>
      </tr>
      <tr style="vertical-align:top">
        <td style="width:181px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">WPF</text></para>
        </td>
        <td style="width:82px;">
          <para styleclass="Normal (list)" style="text-align:center;"><image src="supported.png" scale="100.00%" styleclass="Normal (list)"></image></para>
        </td>
      </tr>
      <tr style="vertical-align:top">
        <td style="width:181px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Silverlight 4</text></para>
        </td>
        <td style="width:82px;">
          <para styleclass="Normal (list)" style="text-align:center;"><image src="supported.png" scale="100.00%" styleclass="Normal (list)"></image></para>
        </td>
      </tr>
      <tr style="vertical-align:top">
        <td style="width:181px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Silverlight 5</text></para>
        </td>
        <td style="width:82px;">
          <para styleclass="Normal (list)" style="text-align:center;"><image src="supported.png" scale="100.00%" styleclass="Normal (list)"></image></para>
        </td>
      </tr>
      <tr style="vertical-align:top">
        <td style="width:181px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Windows Phone 7 Mango</text></para>
        </td>
        <td style="width:82px;">
          <para styleclass="Normal (list)" style="text-align:center;"><image src="notsupported.png" scale="100.00%" styleclass="Normal (list)"></image></para>
        </td>
      </tr>
      <tr style="vertical-align:top">
        <td style="width:181px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Windows Phone 8</text></para>
        </td>
        <td style="width:82px;">
          <para styleclass="Normal (list)" style="text-align:center;"><image src="notsupported.png" scale="100.00%" styleclass="Normal (list)"></image></para>
        </td>
      </tr>
      <tr style="vertical-align:top">
        <td style="width:181px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Windows RT</text></para>
        </td>
        <td style="width:82px;">
          <para styleclass="Normal (list)" style="text-align:center;"><image src="notsupported.png" scale="100.00%" styleclass="Normal (list)"></image></para>
        </td>
      </tr>
      <tr style="vertical-align:top">
        <td style="width:181px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Test/emulation service</text></para>
        </td>
        <td style="width:82px;">
          <para styleclass="Normal (list)" style="text-align:center;"><image src="supported.png" scale="100.00%" styleclass="Normal (list)"></image></para>
        </td>
      </tr>
    </table></para>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Screenshot</text></para>
    <para styleclass="Normal"><image src="services_splashscreenservice.png" scale="100.00%" styleclass="Image Caption"></image></para>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Enqueuing tasks into the SplashScreenService batch</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">First of all is requiered resolve the instance of the registered ISplashScreenService type from the view model:</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">var</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">splashScreenService</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">=</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">GetService&lt;ISplashScreenService&gt;();</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">or from the application bootstrapper, after a previous service registration:</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">ServiceLocator.Instance.RegisterTypeIfNotYetRegistered&lt;ISplashScreenService,</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">SplashScreenService&gt;();</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">/*...*/</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">var</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">splashScreenService</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">=</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">ServiceLocator.Instance.Resolve&lt;ISplashScreenService&gt;();</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">To en-queue tasks use the following code:</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">splashScreenService.Enqueue(</text><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000000;" translate="true">new</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">ActionTask(&quot;Creating the shell&quot;,</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">OnCreateShell));</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">splashScreenService.Enqueue(</text><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000000;" translate="true">new</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">ActionTask(&quot;Initializing modules&quot;,</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">OnInitializeModules));</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">splashScreenService.Enqueue(</text><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000000;" translate="true">new</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">ActionTask(&quot;Starting application&quot;,</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">OnStartApplication));</text></para>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Committing the batch</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">To execute the batch of en-queued tasks, and show the progress through the </text><link displaytype="text" defaultstyle="true" type="topiclink" href="T_Catel_MVVM_Services_IPleaseWaitService" styleclass="Normal" translate="true">IPleaseWaitService</link><text styleclass="Normal" translate="true">, use the following code: </text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">splashScreenService.Commit();</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">To execute the batch of en-queued tasks, and show the progress through the </text><link displaytype="text" defaultstyle="true" type="topiclink" href="T_Catel_MVVM_Services_IUIVisualizerService" styleclass="Normal" translate="true">IUIVisualizerService</link><text styleclass="Normal" translate="true">, use the following code: </text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">splashScreenService.Commit&lt;MySplashScreenViewModel&gt;();</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">or:</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">splashScreenService.Commit(typeof(MySplashScreenViewModel));</text></para>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Committing the batch asynchronously with callback</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">To execute the batch of en-queued tasks asynchronously, and show the progress through the </text><link displaytype="text" defaultstyle="true" type="topiclink" href="T_Catel_MVVM_Services_IPleaseWaitService" styleclass="Normal" translate="true">IPleaseWaitService</link><text styleclass="Normal" translate="true">, use the following code: </text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">splashScreenService.CommitAsync(OnBatchCompleted);</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">To execute the batch of en-queued task asynchronously, and show the progress through the </text><link displaytype="text" defaultstyle="true" type="topiclink" href="T_Catel_MVVM_Services_IUIVisualizerService" styleclass="Normal" translate="true">IUIVisualizerService</link><text styleclass="Normal" translate="true">, use the following code: </text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">splashScreenService.CommitAsync&lt;MySplashScreenViewModel&gt;(OnBatchCompleted);</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">or:</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">splashScreenService.CommitAsync(OnBatchCompleted, typeof(MySplashScreenViewModel));</text></para>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Smooth progress notification of an executing action task</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">To notify the progress of an action task smoothly, use the argument of type </text><link displaytype="text" defaultstyle="true" type="topiclink" href="T_Catel_MVVM_Tasks_ITaskProgressTracker" styleclass="Normal" translate="true">ITaskProgressTracker</link><text styleclass="Normal" translate="true"> just like is used in the following code:</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000000;" translate="true">private void</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">OnInitializeModules(ITaskProgressTracker</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">tracker)</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">{</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true"> &#160; </text><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000000;" translate="true">int</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">registeredModulesCount</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">=</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">0;</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true"> &#160; </text><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000000;" translate="true">foreach</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">(var</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">module</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000000;" translate="true">in</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">ModuleCatalog.Modules)</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true"> &#160; </text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">{</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true"> &#160; &#160; &#160;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">tracker.UpdateStatus((int)(100.0f</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">*</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">(registeredModulesCount</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">/</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">ModuleCatalog.Modules.Count)),</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000000;" translate="true">string</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">.Format(&quot;Registering module &apos;{0}&apos;&quot;,</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">module.ModuleName));</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true"> &#160; &#160; &#160;</text><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000000;" translate="true">if</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">(RegisterModule(module))</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true"> &#160; &#160; &#160;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">{</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true"> &#160; &#160; &#160; &#160;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">registeredModulesCount++;</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true"> &#160; &#160; &#160;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">}</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#ffffff;" translate="true"> &#160; </text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">}</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">}</text></para>
    <para styleclass="Notes"><text styleclass="Notes" translate="true">After committing the batch is cleared, so to execute it again you should en-queue the tasks again</text></para>
    <para styleclass="Notes"><text styleclass="Notes" translate="true">The SplashScreenService is thread-safe</text></para>
  </body>
</topic>
